package com.platform.api.bzproject.controller;


import com.github.pagehelper.PageInfo;
import com.platform.api.bzproject.model.DistributionProfit;
import com.platform.api.bzproject.service.IDistributionProfitService;
import com.platform.common.core.Result;
import com.platform.common.core.ResultCode;
import com.platform.security.util.SecurityUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 分销收益表 前端控制器
 * </p>
 *
 * @author guoshao
 * @since 2021-12-10
 * 源码联系微信：2549789059
 */
@RestController
@RequestMapping("{appid}/u/distributionProfit")
public class DistributionProfitController {

    @Autowired
    private IDistributionProfitService iDistributionProfitService;

    @GetMapping("/list")
    public Result list(DistributionProfit distributionProfit, Integer offset){

        String userId = null;
        try {
            userId = SecurityUtils.getUser().getUserId();
            if(StringUtils.isNotBlank(userId)){
                distributionProfit.setUserId(userId);
            }
        }catch (Exception e){
            return Result.failure(ResultCode.WEB_401,"获取用户信息失败");
        }

        PageInfo<DistributionProfit> pageInfo = iDistributionProfitService.pageInfo(distributionProfit,offset);

        return Result.success(pageInfo);
    }

    @GetMapping("/selectAllProfitList")
    public Result selectAllProfitList(DistributionProfit distributionProfit, Integer offset){

        String userId = null;
        try {
            userId = SecurityUtils.getUser().getUserId();
            if(StringUtils.isNotBlank(userId)){
                distributionProfit.setUserId(userId);
            }
        }catch (Exception e){
            return Result.failure(ResultCode.WEB_401,"获取用户信息失败");
        }

        PageInfo<DistributionProfit> pageInfo = iDistributionProfitService.selectAllProfitList(distributionProfit,offset);

        return Result.success(pageInfo);
    }

}
